import 'package:flutter/material.dart';
class My extends StatelessWidget{
  Widget build(BuildContext context){
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Row(
          children: <Widget>[
            MyButton(width: 300.0,height: 100.0,contText: "调用",clickFn: (){
              print("回调函数");
            },)
          ],
        ),
        Row(
          mainAxisAlignment:MainAxisAlignment.center,
          children: <Widget>[
            ButtonBar(
              children: <Widget>[
                OutlineButton(
                  child: Text("登录"),
                  onPressed: (){

                  },
                ),
                RaisedButton(
                  child: Text("注册"),
                  onPressed: (){

                  },
                ),
              ],
            ),
          ],
        ),
       Row(
         children: <Widget>[
           Expanded(

             child: Container(
               margin: EdgeInsets.all(20),
               height: 50,
               child: OutlineButton(
                 child: Text("注册"),
                 onPressed: (){
                   print("自适应按钮");
                 },
               ),
             ),
           ),
         ],
       ),
        
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
           
            RaisedButton(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20)
              ),
              child: Text("圆角按钮"),
              onPressed: (){
                print("圆角按钮");
              },
            )
            ,
            Container(
              width: 100,
              height: 50,
              child: RaisedButton(
              child: Text("普通按钮"),
              onPressed: (){
                print("普通按钮");
              },
            ),
            ),
            RaisedButton.icon(
              icon: Icon(Icons.search),
              label: Text("带图标按钮"),
              onPressed: (){
                print("图标按钮");
              },
            ),
            
            RaisedButton(
              color: Colors.greenAccent,
              child: Text("颜色",style: TextStyle(color:Colors.blueAccent),),
              elevation: 10,
              onPressed: (){
                print("普通按钮");
              },
            ),
          ],
        )
      ],
    );
  }
}
// 按钮的封装
class MyButton extends StatelessWidget{
  double width;
  double height;
  String contText;
  var clickFn;
  MyButton({this.width=200.0,this.height=50.0,this.contText="封装按钮",this.clickFn=null});
  @override
  Widget build(BuildContext context){
    return Container(
      width: this.width,
      height: this.height,
      child: RaisedButton(
        child: Text(this.contText),
        onPressed: this.clickFn,
      ),
    );
  }
}